//
//  CustomNavigationControllerViewController.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/6.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CustomNavigationControllerViewController: UINavigationController {

    convenience init(rootViewController: CMDBBaseViewController,hideNavBar: Bool) {
        
        self.init(rootViewController : rootViewController)
        
        rootViewController.useInteractivePopGestureRecogmizer()
        
        setNavigationBarHidden(hideNavBar, animated: false)
    }

}

extension CustomNavigationControllerViewController{
    
    func pushViewController(viewController: UIViewController, animated: Bool,isForbiwDraw : Bool) {
        
        if isForbiwDraw {
            NSNotificationCenter.defaultCenter().postNotificationName(ShowSliederDrawerNote, object: nil)
        }
    
        super.pushViewController(viewController, animated: animated)
    }
    
    override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        if (topViewController != nil) {
            
            return topViewController!.supportedInterfaceOrientations()
            
        }else{
            
            return .Portrait
            
        }
    }
    
    override func shouldAutorotate() -> Bool {
        if (topViewController != nil) {
            
            return topViewController!.shouldAutorotate()
            
        }else{
            
            return false
            
        }
    }
    
    override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
        if (topViewController != nil) {
            return topViewController!.preferredInterfaceOrientationForPresentation()
        }else{
            
            return .Portrait
        }
        
    }
    
}